<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>我的团队</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" href="../css/common.css" />
	</head>

	<body>

		<style>
			[v-cloak] {
				display: none;
			}
			
			html,
			body {
				height: 100%;
				background-color: white;
			}
			
			.mui-bar-nav {
				background: #f16456;
				height: 58px;
			}
			
			.mui-bar .mui-title {
				margin-top: 18px;
			}
			
			.mui-bar-nav~.mui-content {
				padding-top: 58px;
			}
			
			.mui-action-back,
			.mui-title,
			.mui-action-back:active {
				color: #FFFFFF!important;
				margin-top: 17px;
			}
			
			.mui-content {
				padding: 0px 3px;
			}
			
			.mui-btn {
				margin-bottom: 5px;
				border: 1px solid #f16456;
				background-color: #f16456;
				color: #FFFFFF;
			}
			
			.mui-btn:active {
				border: 1px solid #de7c79!important;
				background-color: #de7c79!important;
			}
			
			.custom-query input {
				width: 45%;
				height: 30px;
			}
			
			table.gridtable {
				width: 100%;
				font-family: verdana, arial, sans-serif;
				font-size: 11px;
				color: #333333;
				border-width: 1px;
				border-color: #666666;
				border-collapse: collapse;
			}
			
			table.gridtable th {
				border-width: 1px;
				padding: 8px;
				border-style: solid;
				border-color: #666666;
				background-color: #dedede;
			}
			
			table.gridtable td {
				border-width: 1px;
				padding: 8px;
				border-style: solid;
				border-color: #666666;
				background-color: #ffffff;
				text-align: center;
			}
		</style>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">我的团队</h1>
		</header>
		<div class="mui-content" id="bizVue" v-cloak>
			<div class="mui-content-padded">
				<button type="button" class="mui-btn" @click="search(1)">今日</button>
				<button type="button" class="mui-btn" @click="search(2)">本周</button>
				<button type="button" class="mui-btn" @click="search(3)">本月</button>
				<button type="button" class="mui-btn" @click="search(4)">近三个月</button>
				<button type="button" class="mui-btn" @click="setShowCustom">自定义</button>
				<h5 v-if="showCustom">指定日期</h5>
				<div class="custom-query" v-if="showCustom">
					<input type="date" v-model="q.startDate" @change="cusSearch" />至<input type="date" v-model="q.endDate" @change="cusSearch" />
				</div>
			</div>
			<table class="gridtable">
				<tr>
					<td>直推会员</td>
					<td colspan="2">{{myCount.higherOne}}</td>
				</tr>
				<tr>
					<td>二级会员</td>
					<td colspan="2">{{myCount.higherTwo}}</td>
				</tr>
				<tr>
					<td>三级会员</td>
					<td colspan="2">{{myCount.higherThree}}</td>
				</tr>
				<tr>
					<th style="color: #f16456;">{{title}}</th>
					<th>本人</th>
					<th>团队</th>
				</tr>
				<tr>
					<th>充值</th>
					<td>{{myCount.deposit}}</td>
					<td>{{teamCount.deposit}}</td>
				</tr>
				<tr>
					<th>发红包</th>
					<td>{{myCount.sendPacket}}</td>
					<td>{{teamCount.sendPacket}}</td>
				</tr>
				<tr>
					<th>抢红包</th>
					<td>{{myCount.grabPacket}}</td>
					<td>{{teamCount.grabPacket}}</td>
				</tr>
				<tr>
					<th>中雷</th>
					<td>{{myCount.landmine}}</td>
					<td>{{teamCount.landmine}}</td>
				</tr>
				<tr>
					<th>佣金</th>
					<td>{{myCount.commission}}</td>
					<td>{{teamCount.commission}}</td>
				</tr>
			</table>
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/vue.min.js"></script>
		<script type="text/javascript" src="../js/public.js"></script>
		<script>
			mui.init();

			var vm = new Vue({
				el: '#bizVue',
				data: {
					showCustom: false,
					q: {
						startDate: "",
						endDate: ""
					},
					myCount: {},
					teamCount: {},
					title: ""

				},
				mounted: function() {
					mui.plusReady(function() {
						swipeBack();
						vm.search(1);
					});
				},
				methods: {
					setShowCustom: function() {
						vm.showCustom = true;
						vm.title = "自定义";
					},
					search: function(id) {
						var url = null;
						switch(id) {
							case 1:
								url = TodayCount;
								vm.title = "今日";
								break;
							case 2:
								url = WeekCount;
								vm.title = "本周";
								break;
							case 3:
								url = MonthCount;
								vm.title = "本月";
								break;
							case 4:
								url = ThreeMonthCount;
								vm.title = "近三个月";
								break;
						}
						plus.nativeUI.showWaiting("正在查询");
						mui.postParam(url, null, function(result) {
							if(result.code == 0) {
								vm.myCount = result.myCount;
								vm.myCount.sendPacket = Math.abs(vm.myCount.sendPacket);
								vm.teamCount = result.teamCount;
								vm.teamCount.sendPacket = Math.abs(vm.teamCount.sendPacket);
							} else {
								mymui(result.msg);
							}
							plus.nativeUI.closeWaiting();
						});
					},
					cusSearch: function() {
						plus.nativeUI.showWaiting("正在查询");
						mui.postParam(CustomCount, vm.q, function(result) {
							if(result.code == 0) {
								vm.myCount = result.myCount;
								vm.myCount.sendPacket = Math.abs(vm.myCount.sendPacket);
								vm.teamCount = result.teamCount;
								vm.teamCount.sendPacket = Math.abs(vm.teamCount.sendPacket);
							} else {
								mymui(result.msg);
							}
							plus.nativeUI.closeWaiting();
						});
					}
				}
			});
		</script>

	</body>

</html>